package com.yzt.zhuju.dialog;

import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.yzt.zhuju.R;
import com.yzt.zhuju.config.AppConfigCacheManager;
import com.yzt.zhuju.event.RxBus;
import com.yzt.zhuju.event.call.FinishLiveEvent;
import com.yzt.zhuju.utils.RechargeUtil;
import com.yzt.zhuju.utils.ViewUtil;

/**
 * author : bob
 * date   : 2022/11/15
 * desc   : 直播价格的弹窗
 */
public class ChatPriceDialog extends BottomBaseDialog {

    private TextView tvPrice;

    @Override
    public int getLayoutRes() {
        return R.layout.dialog_chat_price;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setStyle(STYLE_NO_TITLE, R.style.DialogBottomCustomStyle_1);
    }

    @Override
    public void bindView(View v) {

        String money = getArguments().getString("user_price");
        String userId = getArguments().getString("user_id");

        tvPrice = v.findViewById(R.id.tv_price);
        tvPrice.setText(money);

        // 审核校验
        if (AppConfigCacheManager.getInstance().getSystemConfig().isExamine()) {
            v.findViewById(R.id.ll_price).setVisibility(View.INVISIBLE);
            v.findViewById(R.id.tv_recharge).setVisibility(View.INVISIBLE);
        }

        // 直接通话
        v.findViewById(R.id.img_call).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (ViewUtil.isFastDoubleClick()) {
                    return;
                }
//                dismissAllowingStateLoss();
              //  ARouter.getInstance().navigation(ICallService.class).callVideo(mActivity, userId);
                RxBus.getDefault().post(new FinishLiveEvent());
            }
        });

        // 充值
        v.findViewById(R.id.tv_recharge).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (ViewUtil.isFastDoubleClick()) {
                    return;
                }
                dismissAllowingStateLoss();
                RechargeUtil.toRecharge(getActivity(), false);
            }
        });
    }
}